package com.cortex.carambolasummary;

import java.util.ArrayList;
import java.util.List;

import com.cortex.carambola.summary.CarambolaSummary;

abstract public class CortexList<T> implements OnActionList{

	@Override
	public void add(CarambolaSummary summary) {
		getList().add(summary);
		summaryAdded(summary);
	}

	@Override
	public void remove(CarambolaSummary summary) {
		if(getList().remove(summary)){
			summaryRemoved(summary);
		}
	}
	@Override
	public void remove(int index) {
		
		remove(getList().get(index));
	}
	@Override
	public List<CarambolaSummary> getData(){
		return getList();
	}
	@Override
	public void clear() {
		getList().clear();
		summariesCleared(getList());
	}
	
	abstract List<CarambolaSummary> getList();
	abstract void summaryAdded(CarambolaSummary summary);
	abstract void summaryRemoved(CarambolaSummary summary);
	abstract void summariesCleared(List<CarambolaSummary> summaries);
	
}